using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;

namespace CKS.InternetExtranet
{
    public class MasterPageFeatureReceiver : SPFeatureReceiver
    {
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPSite site = null;
            try
            {
                site = properties.Feature.Parent as SPSite;
                foreach (SPWeb web in site.AllWebs)
                {
                    web.MasterUrl = "/_catalogs/masterpage/iee.master";
                    web.Update();
                }
            }
            catch (Exception ex)
            {
                Utils.LogError(ex);
            }
        }

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPSite site = null;
            try
            {
                site = properties.Feature.Parent as SPSite;
                foreach (SPWeb web in site.AllWebs)
                {
                    web.MasterUrl = "/_catalogs/masterpage/default.master";
                    web.Update();
                }
            }
            catch (Exception ex)
            {
                Utils.LogError(ex);
            }
        }

        public override void FeatureInstalled(SPFeatureReceiverProperties properties)
        {
        }

        public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
        {
        }
    }
}
